/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * aceleracao.java
 *
 * Created on 26/10/2011, 17:55:30
 */

package br.com.fatecpg.tp1.formularios;

/**
 *
 * @author Fatec
 */
public class Aceleracao extends javax.swing.JInternalFrame {

    /** Creates new form aceleracao */
    public Aceleracao() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        gal = new javax.swing.JLabel();
        unidadegtextfield = new javax.swing.JTextField();
        convertertextfield = new javax.swing.JTextField();
        gravidadetextfield = new javax.swing.JTextField();
        miligaltextfield = new javax.swing.JTextField();
        Pesporsegundo = new javax.swing.JLabel();
        galtextfield = new javax.swing.JTextField();
        metrosporsegundo = new javax.swing.JLabel();
        selecao = new javax.swing.JComboBox();
        converter = new javax.swing.JLabel();
        gravidadepadrao = new javax.swing.JLabel();
        UnidadeG = new javax.swing.JLabel();
        pestextfield = new javax.swing.JTextField();
        metrostextfield = new javax.swing.JTextField();
        miligal = new javax.swing.JLabel();

        setBackground(new java.awt.Color(153, 153, 153));
        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);

        gal.setFont(new java.awt.Font("Candara", 1, 12));
        gal.setText("Gal");
        gal.setBorder(javax.swing.BorderFactory.createCompoundBorder());

        unidadegtextfield.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(51, 51, 51)));
        unidadegtextfield.setEnabled(false);

        gravidadetextfield.setBorder(new javax.swing.border.MatteBorder(null));
        gravidadetextfield.setEnabled(false);

        miligaltextfield.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 51, 51)));
        miligaltextfield.setEnabled(false);

        Pesporsegundo.setFont(new java.awt.Font("Candara", 1, 12));
        Pesporsegundo.setText("Pés por segundo ao quadrado");

        galtextfield.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(51, 51, 51)));
        galtextfield.setCaretColor(new java.awt.Color(255, 255, 255));
        galtextfield.setEnabled(false);

        metrosporsegundo.setFont(new java.awt.Font("Candara", 1, 12));
        metrosporsegundo.setText("Metros por segundo ao quadrado");

        selecao.setFont(new java.awt.Font("Times New Roman", 0, 11));
        selecao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Metros por segundo ao quadrado", "Pés por segundo ao quadrado", "Gal", "MiliGal", "Gravidade Padrão", "Unidade G", " " }));
        selecao.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        selecao.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                selecaoItemStateChanged(evt);
            }
        });
        selecao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                selecaoKeyReleased(evt);
            }
        });

        converter.setFont(new java.awt.Font("Comic Sans MS", 0, 14));
        converter.setForeground(new java.awt.Color(204, 0, 0));
        converter.setText("Quero converter:");

        gravidadepadrao.setFont(new java.awt.Font("Candara", 1, 12));
        gravidadepadrao.setText("Gravidade padrão");

        UnidadeG.setFont(new java.awt.Font("Candara", 1, 12));
        UnidadeG.setText("Unidade G");

        pestextfield.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(51, 51, 51)));
        pestextfield.setEnabled(false);

        metrostextfield.setBorder(new javax.swing.border.MatteBorder(null));
        metrostextfield.setEnabled(false);

        miligal.setFont(new java.awt.Font("Candara", 1, 12));
        miligal.setText("MiliGal");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(converter)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(convertertextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(selecao, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(64, 64, 64)))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(metrosporsegundo)
                                    .addComponent(gravidadepadrao)
                                    .addComponent(UnidadeG)
                                    .addComponent(miligal)
                                    .addComponent(Pesporsegundo))
                                .addGap(10, 10, 10))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(gal, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(galtextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                            .addComponent(gravidadetextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                            .addComponent(miligaltextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                            .addComponent(pestextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                            .addComponent(metrostextfield, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                            .addComponent(unidadegtextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE))
                        .addGap(167, 167, 167))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(converter)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(convertertextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(selecao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(metrostextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(metrosporsegundo))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(pestextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Pesporsegundo))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(galtextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(gal))
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(miligal)
                    .addComponent(miligaltextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(gravidadepadrao)
                    .addComponent(gravidadetextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(UnidadeG)
                    .addComponent(unidadegtextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(108, 108, 108))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void selecaoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_selecaoItemStateChanged

        if(selecao.getSelectedItem().equals("Metros por segundo ao quadrado")){
            metrostextfield.setText("");
            pestextfield.setText("");
            galtextfield.setText("");
            miligaltextfield.setText("");
            gravidadetextfield.setText("");
            unidadegtextfield.setText("");
            String s=convertertextfield.getText();
            metrostextfield.setText(s);
            Double num =Double.parseDouble(convertertextfield.getText());

            Double res=num*100;
            galtextfield.setText(res.toString());
            res=num*3.2808333333;
            pestextfield.setText(res.toString());
            res=num*100000;
            miligaltextfield.setText(res.toString());
            res=num*0.1019716213;
            gravidadetextfield.setText(res.toString());
            res=num*0.1019716213;
            unidadegtextfield.setText(res.toString());



        } else if(selecao.getSelectedItem().equals("Pés por segundo ao quadrado")){
            metrostextfield.setText("");
            pestextfield.setText("");
            galtextfield.setText("");
            miligaltextfield.setText("");
            gravidadetextfield.setText("");
            unidadegtextfield.setText("");
            String s=convertertextfield.getText();
            pestextfield.setText(s);
            Double num =Double.parseDouble(convertertextfield.getText());
            Double res=num*0.304806096;
            metrostextfield.setText(res.toString());
            res=num*30.480061;
            galtextfield.setText(res.toString());
            res=num*30480.06096;
            miligaltextfield.setText(res.toString());
            res=num*0.0311081;
            gravidadetextfield.setText(res.toString());
            res=num*0.0311081;
            unidadegtextfield.setText(res.toString());


        } else if(selecao.getSelectedItem().equals("Gal")){
            metrostextfield.setText("");
            pestextfield.setText("");
            galtextfield.setText("");
            miligaltextfield.setText("");
            gravidadetextfield.setText("");
            unidadegtextfield.setText("");
            String s=convertertextfield.getText();
            galtextfield.setText(s);
            Double num =Double.parseDouble(convertertextfield.getText());
            Double res=num*0.01;
            metrostextfield.setText(res.toString());
            res=num*0.032308;
            pestextfield.setText(res.toString());
            res=num*1;
            galtextfield.setText(res.toString());
            res=num*1000;
            miligaltextfield.setText(res.toString());
            res=num*0.00102;
            gravidadetextfield.setText(res.toString());
            res=num*0.00102;
            unidadegtextfield.setText(res.toString());

        } else if (selecao.getSelectedItem().equals("MiliGal")){
            metrostextfield.setText("");
            pestextfield.setText("");
            galtextfield.setText("");
            miligaltextfield.setText("");
            gravidadetextfield.setText("");
            unidadegtextfield.setText("");
            String s=convertertextfield.getText();
            miligaltextfield.setText(s);
            Double num =Double.parseDouble(convertertextfield.getText());
            Double res=num*0.00001;
            metrostextfield.setText(res.toString());
            res=num*(double)0.000033;
            pestextfield.setText(res.toString());
            res=num*0.001;
            galtextfield.setText(res.toString());
            res=num*1;
            miligaltextfield.setText(res.toString());
            res=num*0.000001;
            gravidadetextfield.setText(res.toString());
            res=num*0.000001;
            unidadegtextfield.setText(res.toString());
        }

        else if (selecao.getSelectedItem().equals("Gravidade Padrão")){
            metrostextfield.setText("");
            pestextfield.setText("");
            galtextfield.setText("");
            miligaltextfield.setText("");
            gravidadetextfield.setText("");
            unidadegtextfield.setText("");
            String s=convertertextfield.getText();
            gravidadetextfield.setText(s);
            Double num =Double.parseDouble(convertertextfield.getText());
            Double res=num*10;
            metrostextfield.setText(res.toString());
            res=num*32;
            pestextfield.setText(res.toString());
            res=num*981;
            galtextfield.setText(res.toString());
            res=num*980665;
            miligaltextfield.setText(res.toString());
            res=num*1;
            gravidadetextfield.setText(res.toString());
            res=num*1;
            unidadegtextfield.setText(res.toString());
        }

        else if (selecao.getSelectedItem().equals("Unidade G")){
            metrostextfield.setText("");
            pestextfield.setText("");
            galtextfield.setText("");
            miligaltextfield.setText("");
            gravidadetextfield.setText("");
            unidadegtextfield.setText("");
            String s=convertertextfield.getText();
            unidadegtextfield.setText(s);
            Double num =Double.parseDouble(convertertextfield.getText());
            Double res=num*10;
            metrostextfield.setText(res.toString());
            res=num*32;
            pestextfield.setText(res.toString());
            res=num*981;
            galtextfield.setText(res.toString());
            res=num*980665;
            miligaltextfield.setText(res.toString());
            res=num*1;
            gravidadetextfield.setText(res.toString());
            res=num*1;
            unidadegtextfield.setText(res.toString());
        }

    }//GEN-LAST:event_selecaoItemStateChanged

    private void selecaoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_selecaoKeyReleased
        if(selecao.getSelectedItem().equals("Gal")){
            String s=convertertextfield.getText();
            gal.setText(s);
        }
}//GEN-LAST:event_selecaoKeyReleased


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Pesporsegundo;
    private javax.swing.JLabel UnidadeG;
    private javax.swing.JLabel converter;
    private javax.swing.JTextField convertertextfield;
    private javax.swing.JLabel gal;
    private javax.swing.JTextField galtextfield;
    private javax.swing.JLabel gravidadepadrao;
    private javax.swing.JTextField gravidadetextfield;
    private javax.swing.JLabel metrosporsegundo;
    private javax.swing.JTextField metrostextfield;
    private javax.swing.JLabel miligal;
    private javax.swing.JTextField miligaltextfield;
    private javax.swing.JTextField pestextfield;
    private javax.swing.JComboBox selecao;
    private javax.swing.JTextField unidadegtextfield;
    // End of variables declaration//GEN-END:variables

}
